package com.yiku.entity;

import com.yiku.common.Constant;
import com.yiku.common.U9CloudDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @Author=ludada
 * @Date=2024/02/23 15=32
 */
@Data
@ApiModel("U9C新增料品请求实体类")
@Accessors(chain = true)
public class ItemMasterAddDTO {
    @Autowired
   static U9CloudDTO u9CloudDTO;

    @ApiModelProperty("三方id")
    private String OtherID = "1";
    @ApiModelProperty("编码")
    private String Code;
    @ApiModelProperty("料品名称")
    private String Name;
    @ApiModelProperty("规格")
    private String SPECS;
    private Boolean IsVarRatio = true;
    private Boolean IsInventoryEnable = true;
    private Boolean IsPurchaseEnable = true;
    private Boolean IsSalesEnable = true;
    private Boolean IsBuildEnable = true;
    private Boolean IsOutsideOperationEnable = true;
    private Boolean IsMRPEnable = true;
    private Boolean IsBOMEnable = true;
    private Boolean IsGradeControl = false;
    private Boolean IsPotencyControl = false;
    private int StandardGrade = -1;
    private int StartGrade = -1;
    private int EndGrade = -1;
    private int StandardPotency = -1;
    private int StartPotency = -1;
    private int EndPotency = -1;
    private int State = 2;
    private int ItemForm = -1;
    private int ItemFormAttribute = 10;
    //料品库存相关信息
    private InventoryInfo InventoryInfo = new InventoryInfo();
    private Effective Effective = new Effective();
    private MainItemCategory MainItemCategory = new MainItemCategory();
    private Org Org = new Org();
    private Code InventoryUOM = new Code();
    //料品采购相关信息
    private PurchaseInfo PurchaseInfo =new PurchaseInfo();
    //料品生产相关信息
    //private MfgInfo MfgInfo =new MfgInfo();
    //料品销售相关信息
    private SaleInfo SaleInfo =new SaleInfo();
    //转换率策略
    private int ConverRatioRule = 2;
    
    @ApiModelProperty("私有段")
    private DescFlexField DescFlexField;
    
    @Data
    public static class DescFlexField{

       @ApiModelProperty("--")
        private String  PrivateDescSeg1="" ;
       @ApiModelProperty("颜色明细")
        private String  PrivateDescSeg2="" ;
       @ApiModelProperty("支数(每袋)")
        private String  PrivateDescSeg3=""  ;
       @ApiModelProperty("中包数(每箱)")
        private String  PrivateDescSeg4 =""   ;
       @ApiModelProperty("袋数(每箱)")
        private String  PrivateDescSeg5 =""  ;
       @ApiModelProperty("总包数(每箱/公式)")
        private String  PrivateDescSeg6=""   ;
       @ApiModelProperty("换算率(公式)")
        private String  PrivateDescSeg7=""  ;
       @ApiModelProperty("受否按样")
        private String  PrivateDescSeg8="" ;
       @ApiModelProperty("货号")
        private String  PrivateDescSeg9=""   ;
       @ApiModelProperty("单支克重")
        private String  PrivateDescSeg10 =""  ;
//       private String  PrivateDescSeg11   ;
//       private String  PrivateDescSeg12   ;
//       private String  PrivateDescSeg13  ;
//       private String  PrivateDescSeg14  ;
//       private String  PrivateDescSeg15  ;
//       private String  PrivateDescSeg16  ;
                  

    }




    @ApiModelProperty("库存副单位")
    private Code InventorySecondUOM;

    @ApiModelProperty("销售单位")
    private Code SalesUOM;

    @ApiModelProperty("采购单位")
    private Code PurchaseUOM;

    @ApiModelProperty("生产单位")
    private Code ManufactureUOM;

    @ApiModelProperty("领料单位")
    private Code MaterialOutUOM;

    @ApiModelProperty("计价单位")
    private Code PriceUOM;

    @ApiModelProperty("重量单位")
    private Code WeightUom;

    @ApiModelProperty("库存单位重量")
    private double Weight;



    @ApiModelProperty("成本单位")
    private Code CostUOM;

    @ApiModelProperty("体积单位")
    private Code BulkUom;

    @Data
    public static class SaleInfo {
        //可用量检查
        private boolean IsAvailableQtyCheck = true;
        //出货后续调价
        private boolean IsAdjustPriceAfterShip = true;
        //可用量规则 select * from CBO_AvailableQtyRule t inner join CBO_AvailableQtyRule_trl a on t.id = a.id  where org = 1002312110110026
        private long AvailableQtyRule = 1002401190000166L;
        //限价依据
        private int LimitPriceBy = -1;

        //系列件层级
        private int FamilyLayer = -1;


        //销售贸易路径可改
        private boolean IsSDTradePathModify = true;
        //销售退货贸易路径可改
        private boolean IsSDRtnTradePathModify = true;
        //供应来源  	当前组织	3
        private int SupplySource = 4;
        //供应组织

        private Code SupplyOrg = new Code(Constant.orgCode);
        //可退换
        private boolean IsReturnable =true ;
        //退货可改
        private boolean IsRMAAllowModify = true;



    }
//     @Data
//    public static class MfgInfo {
//        //番号比对规则
//        private boolean DesignationRule = false;
//        //继承母项番号
//        private boolean IsInheritBomMasterNo = false;
//
//    }


    @Data
    public static class PurchaseInfo {
        //可事后定价
        private boolean IsConfirmOnFinished = true;
        //收货程序 收货-入库
        private int ReceiptMode = 0;
        //收货原则
        private Code ReceiptRule = new Code("01");
        //采购贸易路径可改
        private boolean IsPUTradePathModify = true;
        //采购退货贸易路径可改
        private boolean IsPURtnTradePathModify = true;

    }


    @Data
    public static class InventoryInfo {
        /**
         *拣货规则
         * select * from CBO_PickBy t inner join cbo_pickby_trl a on t.id = a.id where PickSnBy = 0
         */

        private long PickingRule = 1002312120003649L;
        private int InventoryPlanningMethod = 4;
        private int InventoryPlanTime = -1;
        private int PurchaseControlMode = 1;
        private int ReserveMode = -1;
        private int SupplyMethod = -1;
        //批号参数
        private LotParam LotParam = new LotParam();
    }

    /**
     * 批号参数
     */
    @Data
    public static class LotParam {
        private String Code = "ST01";
    }

    /**
     * 有效性
     */
    @Data
    public static class Effective {
        //是否生效 是
        private Boolean IsEffective = true;
        //生效日期
        private String EffectiveDate = DateTimeFormatter.ofPattern("yyyy.MM.dd").format(LocalDateTime.now());
        //失效日期
        private String DisableDate = "9999.12.31";
    }

    /**
     * 主分类
     */
    @Data
    public static class MainItemCategory {
        //分类编码
        private String Code;
    }

    /**
     * 组织
     */
    @Data
    public static class Org {
        //组织编码
        private String Code = "01";
    }

    /**
     * 库存单位
     */
//    @Data
//    public static class Code {
//        //计量单位编码
//        private String Code = "";
//        private String name = "";
//
//        public Code(String code) {
//            Code = code;
//        }
//        public Code( ) {
//
//        }
//    }


}
